#ifndef GRAPHICS_H
#define GRAPHICS_H

#include <list>
using namespace std;

class Texture;
class Rect;

class RenderInfo
{
public:
	Texture* texture;
	Rect* src; 
	Rect* des;
	float alpha;
	float deep;
	float angle;
	
	RenderInfo(Texture* texture, Rect* src, Rect* des, float angle, float alpha, float deep);
	~RenderInfo();
	
};

class Graphics
{
private:
	static Graphics* instance;
	int width;
	int height;

	/*
	Vertices array:

	1***2
	*   *
	3***4
	
	*/

	float texCoors[8];				// Texture coordinate (correlative source rect to draw)
	float verticesArray[12];				// Destination rect to draw texture
	list<RenderInfo*> renderInfos;
	
	Graphics();
	void RenderATexture(RenderInfo* renderInfo);
public:
	static Graphics* GetInstance();
	void Init(int width, int height);

	// Draw texture (in fact, it only put texture to list renderInfos, 
	// and only draw when call RenderAll function.
	void RenderTexture(Texture* texture, Rect* src, Rect* des, float angle, float alpha, float deep);
	
	//Call this function to final draw texture.
	void RenderAll();
	void Destroy();
	~Graphics();
};

#endif